<%@page contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>

<script type="text/javascript">
	var form_url = $.webapp.root+"/admin/system/holiday/add.do" ;
	var org_type ;
	$(function() {
		
		org_type = $("#org_type").combobox({
			valueField: 'label', textField: 'value', value: '1',
			data: [{ label: '0', value: '正常上班' },{ label: '1', value: '节假日' },{ label: '2', value: '补休' }],
			panelHeight:'auto', editable:false, autoShowPanel: true
		}) ;
		
		//编辑，加载表单数据
		if($('input[name=id]').val().length > 0) {
			form_url = $.webapp.root+"/admin/system/holiday/update.do" ;
			$.post($.webapp.root+"/admin/system/holiday/get.do", {id:$('input[name=id]').val()}, function(result) {
				if (result.id != undefined) {
					$('#form').form('load', result);
				}
			}, 'json').error(function() { $.easyui.loaded(); });
		} 
	});
	
	
	//提交表单数据
	var submitNow = function($d, $dg, flag) {
		var o = $("#form").form("getData") ;
		if(o.holidayDate == "") {
			$.messager.alert("提示", "日期不能为空", "info");$.easyui.loaded();return ;
		}
		$.post(form_url, o, function(result) {
			if (result.status) {
				$dg.datagrid('reload');alertify.success(result.msg);$.easyui.loaded();
				if(flag==undefined||flag==false){$d.dialog("close") ;}
			} else {
				$.easyui.loaded();$.messager.alert("错误", result.msg, "error");
			}
		}, 'json').error(function() { $.easyui.loaded(); });
	};
	
	//验证表单
	var submitForm = function($d, $dg, flag) { 
		if($('#form').form('validate')) {
			$.easyui.loading({ msg: "数据提交中，请稍等..." });
			submitNow($d, $dg, flag) ;
		}
	};
	
	
</script>

<form id="form" class="easyui-form form_container">
	<input type="hidden" name="id" value="${id}" />
	<table class="tableform">
		<tr>
			<th>节日名称：</th>
			<td><input name="title" class="easyui-validatebox" type="text" data-options="required: true" /></td>
		</tr>
		<tr>
			<th>节日类型：</th>
			<td><input id="org_type" name="type" style="width:219px;height:25px;" class="easyui-validatebox" type="text" />
			</td>
		</tr>
		<tr>
			<th>日期：</th>
			<td>
				<input name="holidayDate" class="Wdate" style="height:23px;width:217px;" type="text" onFocus="WdatePicker({
				isShowClear:true,
				readOnly:true
				})"/>									
			</td>
		</tr>
	</table>
</form>
